Skip to content

Upgrade Babel packages to 8.x - #4587

Merged
akira28 merged 2 commits into
mainfrom
deps/babel-8
Oct 26, 2026
Merged

akira28 merged 2 commits into
mainfrom
deps/babel-8

Conversation

@akira28

@akira28 akira28 commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Moves all four Babel packages to 8.x in one change and adapts the Jest setup, so the frontend tests pass again on Babel 8.

Affects: Internals only

Prompt summary: The automatic Dependabot PRs that bump Babel to 8.x fail CI. This PR updates everything that can move to Babel 8 together and fixes what breaks.

Why

Babel 8 peers on itself, so Dependabot's single-package PRs (#4577, #4578) cannot pass: preset-typescript@8 needs @babel/core@8. Babel 8 also needs Node 22.18 or later, while .nvmrc pins 22.16.0. Several Babel defaults change and break the Jest transforms.

What

Babel and Node versions

@babel/core, preset-env, preset-react and preset-typescript move to 8.x together. .nvmrc and the Node version in CONTRIBUTING.md move to 22.18.0, the oldest release Babel 8 supports.

Jest transforms

preset-env no longer converts ESM to CommonJS by default, so jest.config.js and svgTransform.js set modules: 'commonjs'. Without it, jest.resetModules() stops isolating dynamic import() and SVG imports fail. preset-react now applies only to .tsx and .js files, because JSX parsing on .ts files breaks generic arrows such as <T>(key: string) => ....

Type-only imports

preset-typescript keeps imports that only carry types. hljs.ts and hljs-languages.ts import LanguageFn with import type. A runtime require('highlight.js') loaded every language and defeated the lazy loading the tests check.

Stale Parcel references

The frontend builds with Vite, but AGENTS.md, CONTRIBUTING.md, source comments and ignore files still named Parcel. They now name Vite. Dead .parcel-cache entries are removed.

Verify

cd src/Elastic.Documentation.Site
npm ci
npm run test
npm run compile:check
npm run lint
npm run build

This PR supersedes #4577 and #4578, which Dependabot can close once this merges.

Babel 8 peers on itself, so core, preset-env, preset-react and
preset-typescript must move together. This replaces the failing
Dependabot PRs for @babel/core and @babel/preset-typescript.

Babel 8 needs Node 22.18 or later, so .nvmrc moves from 22.16.0.
The Jest setup changes to match Babel 8 behaviour:

- preset-env now keeps ESM unless told otherwise, so Jest sets
  modules to commonjs.
- preset-react no longer runs on .ts files, because JSX parsing
  breaks generic arrow functions.
- preset-typescript keeps unused imports, so type-only imports of
  highlight.js use import type.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@akira28
akira28 requested a review from a team as a code owner October 26, 2026 15:14
@akira28
akira28 requested a review from reakaleek October 26, 2026 15:14
The frontend builds with Vite, but docs, comments and ignore files
still named Parcel. Update them so the text matches the toolchain.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Docs preview (local build)

Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/4587/

Sample changed pages:

@akira28
akira28 enabled auto-merge (squash) October 26, 2026 15:37
@akira28
akira28 merged commit 372a64e into main Oct 26, 2026
32 checks passed
@akira28
akira28 deleted the deps/babel-8 branch October 26, 2026 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants